package com.zts.base.page;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Zhangkh on 2017/5/31.
 */
public class PagedList<T> extends ArrayList<T> {

    private Long total;

    private Long offset;

    private Long limit;

    public PagedList() {
    }

    public PagedList(List<T> list) {
        addAll(list);
    }

    @JsonProperty
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    @JsonProperty
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Long getOffset() {
        return offset;
    }

    public void setOffset(Long offset) {
        this.offset = offset;
    }

    @JsonProperty
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Long getLimit() {
        return limit;
    }

    public void setLimit(Long count) {
        this.limit = count;
    }

    @JsonProperty
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Long getCount() {
        return (long)this.size();
    }

    @JsonProperty
    public List<T> getItems() {
        return this;
    }

}